//
//  HintLayer.cpp
//  NinjaTurtle
//
//  Created by Nguyen Tri Chung on 2/4/15.
//
//

#include "HintLayer.h"

HintLayer::HintLayer(View* parent) {
    this->parent = parent;
    this->autorelease();
    
    Size winSize = Director::getInstance()->getWinSize();
    this->textLayer = LayerColor::create(Color4B(0, 0, 0, 100));
    this->textLayer->setAnchorPoint(Point(0, 1));
    this->textLayer->setContentSize(Size(winSize.width, 80));
    this->textLayer->setPosition(0, winSize.height - 120);
    
    this->textLabel = CNodeUtil::createLabelTTF("", 12, FONT_ARCADE);
    this->textLabel->setColor(Color3B::WHITE);
    this->textLabel->setPosition(winSize.width / 2, this->textLayer->getContentSize().height / 2);
    this->textLabel->setDimensions(winSize.width - 50, 0);
    this->textLabel->setHorizontalAlignment(TextHAlignment::CENTER);
    this->textLayer->addChild(this->textLabel);
    
    this->textLayer->setOpacity(0);
    this->textLabel->setOpacity(0);
    this->addChild(this->textLayer);
}

HintLayer::~HintLayer() {
}

void HintLayer::showHint(const string& hint) {
    this->textLabel->setString(hint);
    this->textLayer->runAction(FadeTo::create(0.5f, 100));
    this->textLabel->runAction(FadeIn::create(0.5f));
}

void HintLayer::hideHint() {
    this->textLayer->runAction(FadeOut::create(0.5f));
    this->textLabel->runAction(FadeOut::create(0.5f));
}